#include <stdio.h>

int main()
{
    char buffer[] = "    I   am  good  student          ";
    int pos = 0;
    int loop[50] = {0};
    int len = sizeof(buffer) / sizeof(buffer[0]);
    for (int idx = 1; idx < len; idx++)
    {
        if (buffer[idx] != ' '||(buffer[idx]==' '&&buffer[idx-1]!=' '))
        {
            loop[pos] = idx;
            pos++;
        }
    }
    pos = 0;
    for (int idx = 0; idx < len; idx++)
    {
            if (buffer[idx] == ' ')
            {
                buffer[idx] = buffer[loop[pos]];
                buffer[loop[pos]] = ' ';
                pos++;
                if (loop[pos] == 0)
                {
                    break;
                }
            }
    }
    printf("%s\n", buffer);
}